﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FaceAppClient.Baidu.FaceAPI
{
    public class FileUtils
    {
        public static string getFileBase64(string imagePath)
        {
            string base64 = "";
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(imagePath);
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                byte[] arr1 = new byte[ms.Length];
                ms.Position = 0;
                ms.Read(arr1, 0, (int)ms.Length);
                ms.Close();
                base64 = Convert.ToBase64String(arr1);
            }
            return base64;
        }
    }
}
